package logic;

import java.util.Comparator;

public class PointD implements Cloneable {
	protected double X = 0.0, Y = 0.0;
	protected Line parent = null;
	
	public int meta1 = 0, meta2 = 0, meta3 = 0;
	
	public Line getParent() {
		return parent;
	}

	public void setParent(Line parent) {
		this.parent = parent;
	}

	public PointD() { }
	
	public PointD(double x, double y)
	{
		this.X = x;
		this.Y = y;
	}
	
	public double getX() { return X; }
	public double getY() { return Y; }
	
	public void setPosition(double x, double y)
	{
		this.X = x;
		this.Y = y;
	}
	
	public String toString()
	{
		return "[Point : " + X + ", " + Y + "]";
	}
	
	public boolean equals(PointD p)
	{
		return (p.X == X && p.Y == Y);
	}
	
	public static final Comparator<PointD> ByX = new Comparator<PointD>() {
		
		@Override
		public int compare(PointD arg0, PointD arg1) {
			if(arg0.meta2 == -1)
				return -1;
			if(arg1.meta2 == -1)
				return 1;
			return Double.compare(arg0.X, arg1.X);
		}
	};
}
